<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>P35 2.4.9 【案例】计算圆的周长和面积</title>
    <div>
        <p>圆的半径：<input id="r" type="text"></p>
        <p>圆的周长：<input id="cir" type="text"></p>
        <p>圆的面积：<input id="area" type="text"></p>
    </div>
</head>

<body>
    <script>
        var r = prompt('请输入圆的半径');
        r = parseFloat(r) && Number(r);
        if (!isNaN(r)) {
            var cir = 2 * Math.PI * r;
            var area = Math.PI * r * r;
            document.getElementById('r').value = r;
            document.getElementById('cir').value = cir.toFixed(2);
            document.getElementById('area').value = area.toFixed(2);
        } else {
            alert('请输入正确的数字');
        }
    </script>
    <a href="../首页/page02.html">
        <h2>返回上一页面</h2>
    </a>
</body>

</html>